<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('流程定义明细列表')"/>
    <th:block th:include="include :: jasny-bootstrap-css"/>
</head>
<body class="gray-bg">
<div class="container-div">
    <div class="row">
        <div class="col-sm-12 search-collapse">
            <form id="formId">
                <div class="select-list">
                    <ul>
                        <li class="select-time">
                            <label>部署时间：</label>
                            <input type="text" class="time-input" id="startTime" placeholder="开始时间"
                                   name="params[beginDeployTime]"/>
                            <span>-</span>
                            <input type="text" class="time-input" id="endTime" placeholder="结束时间"
                                   name="params[endDeployTime]"/>
                        </li>
                        <li>
                            <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i
                                    class="fa fa-search"></i>&nbsp;搜索</a>
                            <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i
                                    class="fa fa-refresh"></i>&nbsp;重置</a>
                        </li>
                    </ul>
                </div>
            </form>
        </div>
        <div class="btn-group-sm" id="toolbar" role="group">
          <div id="uploadBtn" class="fileinput fileinput-new" data-provides="fileinput">
                <span class="btn btn-outline-secondary btn-file">
                <span class="fileinput-new">
                <a class="btn btn-warning btn-sm"><i class="fa fa-upload"></i>&nbsp;部署</a>
                </span>
                <span class="fileinput-exists">Change</span>
                <input type="file" name="processDefinition" multiple>
                </span>
                <span class="fileinput-filename"></span>
                <a href="#" class="close fileinput-exists" data-dismiss="fileinput" style="float: none">&times;</a>
          </div>
        </div>
        <div class="col-sm-12 select-table table-striped">
            <table id="bootstrap-table"></table>
        </div>
    </div>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: jasny-bootstrap-js"/>
<script th:inline="javascript">
    var definitionInfoId = [[${definitionInfoId}]];
    var editFlag = [[${@permission.hasPermi('business:definitionDetail:edit')}]];
    var removeFlag = [[${@permission.hasPermi('business:definitionDetail:remove')}]];
    var prefix = ctx + "business/definitionDetail";

    $(function () {
        var options = {
            url: prefix + "/list?definitionInfo.id=" + definitionInfoId,
            exportUrl: prefix + "/export",
            modalName: "流程定义明细",
            columns: [{
                checkbox: true
            },
                {
                    field: 'definitionInfo.name',
                    title: '流程名称',
                },
                {
                    field: 'definitionInfo.' +
                        'description',
                    title: '描述信息',
                },
                {
                    field: 'deployTime',
                    title: '部署时间'
                },
                {
                    field: 'deployKey',
                    title: '部署key',
                },
                {
                    field: 'deploymentId',
                    title: '流程部署id',
                },
                {
                    field: 'version',
                    title: '版本號',
                },
                {
                    field: 'resourceName',
                    title: '查看流程文件',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<a class="btn btn-success btn-xs " href="/business/definitionDetail/readResource?type=xml&deploymentId='+row.deploymentId+'" target="_blank"><i class="fa fa-search"></i></a>';
                    }
                },
                {
                    field: 'resourceName',
                    title: '查看流程图',
                    align: 'center',
                    formatter: function (value, row, index) {
                        return '<a class="btn btn-success btn-xs " href="/business/definitionDetail/readResource?type=png&deploymentId='+row.deploymentId+'" target="_blank"><i class="fa fa-search"></i></a>';
                    }
                }
                ]
        };
        $.table.init(options);
        inituploadBtn();
    });

function inituploadBtn() {
    $('#uploadBtn').on("change.bs.fileinput",function () {
        var formData = new FormData();

        formData.append("processDefinition",$('[name=processDefinition]')[0].files[0]);
        formData.append("definitionInfoId",definitionInfoId);

        $.ajax({
            url:"/business/definitionDetail/upload",
            type:"post",
            data:formData,
            processData : false,
            contentType : false,
            success:function (data) {
                    $('#uploadBtn').fileinput('reset'); //重置
                    $.operate.ajaxSuccess(data);
            }
        });
    })
}

</script>
</body>
</html>